#!/usr/bin/python
#Filename: pickling.py

import cPickle as p
#import pickle as p  #same as last line ,but the last line is faster than this one

shoplistfile = 'shoplist.data'
shoplist = ['apple', 'mango', 'carrot']

#write to the file
f = file(shoplistfile, 'w');
p.dump(shoplist, f)
f.close()

del shoplist

#Read back from the storage
f = file(shoplistfile)
storedlist = p.load(f)
print storedlist
